package com.ruoyi.project.app.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

@Component
public class GlobalInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpServletResponseWrapper httpResponse = new HttpServletResponseWrapper((HttpServletResponse) response);
        String path=request.getRequestURI();

        if(path.equals("/user/testConn1")){
            path = "/user/testConn";
            request.getRequestDispatcher(path).forward(request,response);
            //return false make cur connection/response alive
            return false;
        }
        return true;
    }
}
